import os
path = os.getcwd()+"\\サクラメントの十二宫 乱れる仔ひつじと手懐く狼\\"
dirs = os.listdir(path+"NativeScript\\")
for dir in dirs:
    print(dir)
    list = []
    f1 = open(path+"NativeScript\\"+"01_seep_01.txt","r",encoding="utf-8")
    text_lines = f1.readlines()
    for line in text_lines:
        if "[movie file=" in line:
            list.append("$ renpy.movie_cutscene("+line[line.find("=")+1:line.rfind("]")]+")")
        if "[背景 file=" in line:
            if line[16] == "\"":
                list.append("scene bg "+line[10:16])
                continue
            else:
                list.append("scene bg "+line[10:15])
                continue
        if "[イベントCG file=" in line:#cg
            list.append("scene bg "+line[14:20])
            continue
        if "BGM再生" in line:#bgm
            list.append("play music \"audio/"+line[13:len(line)-3]+".mp3\"")
            continue
        if "SE再生" in line:#se
            list.append("voice \"audio/"+line[12:len(line)-12]+".mp3\"")
            continue
        if "#stext" in line:#text
            if "アリッサ" in line:
                if line[line.rfind("ari"):line.rfind("ari")+8] == "":
                    list.append("ari \""+line[line.rfind("「")+1:len(line)-2]+"\"")
                    continue
                else:
                    list.append("voice \""+line[line.rfind("ari"):line.rfind("ari")+8]+".ogg\"")
                    list.append("ari \""+line[line.rfind("「")+1:len(line)-2]+"\"")
                    continue
            if "ひつじ" in line:
                if line[line.rfind("hit"):line.rfind("hit")+8] == "":
                    list.append("hit \""+line[line.rfind("「")+1:len(line)-2]+"\"")
                    continue
                else:
                    list.append("voice \""+line[line.rfind("hit"):line.rfind("hit")+8]+".ogg\"")
                    list.append("hit \""+line[line.rfind("「")+1:len(line)-2]+"\"")
                    continue
        if "#wtext" in line:
            list.append("\""+line[28:len(line)-1]+"\"")
            continue
        if ";↓" in line:
            list.append("\""+line[7:len(line)-1]+"\"")
            continue
        if "#立ち絵表示" in line:
            if "#立ち絵表示予約" in line:
                if "," not in line:
                    list.append("show "+line[9:line.find("\n")])
                    continue
                elif line[line.find(",")+2] != "\n":
                    list.append("show "+line[9:line.find(",")] + " at "+line[line.find(",")+1:line.find(",")+3])
                    continue
            elif line[line.find(",")+2] == ",":
                list.append("show "+line[7:line.find(",")] + " at "+line[line.find(",")+1])
                continue
            else:
                list.append("show "+line[7:line.find(",")] + " at "+line[line.find(",")+1:line.find(",")+3])
                continue
        if "#立ち絵消去" in line:
            if "#立ち絵消去予約" in line:
                list.append("hide "+line[9:12])
                continue
            else:
                list.append("hide "+ line[7:10])
                continue
        if "jump" in line:
            list.append("menu:")
            list.append("jump "+line[line.find("\"")+1:line.rfind("\"")])
            continue
        if "*固定視点" in line:
            list.append("label "+line[6:len(line)-1]+":")
            continue
        if "mark" in line:
            list.append("\""+line[:line.rfind("mark")]+"\"")
            continue
        if line[0] != "\n" and line[0] != "#" and line[0] != ";" and line[0] != "/" and line[0] != "*" and line[0] != "[" and line[0] != "	":
            list.append("\""+line[:len(line)-1]+"\"")
            continue
    f1.close()
    with open(path+"RenpyOriginalScript\\"+dir,"w",encoding="utf-8") as f2:
        for ScriptText in list:
            f2.write(ScriptText+"\n")